﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Data.OleDb;
using winform;
using System.Data;

namespace 开单
{
    class XsmxDao
    {
        /// <summary>
        /// 添加销售明细
        /// </summary>
        /// <param name="XsmxEntity">销售明细实体类</param>
        public void Addxsmx(XsmxEntity xsmxEntity)
        {
            string sql = string.Empty;
            OleDbParameter[] parameters = {
                     new OleDbParameter("@xsmx_pm", xsmxEntity.xsmx_pm),
                     new OleDbParameter("@xsmx_dj", xsmxEntity.xsmx_dj),
                     new OleDbParameter("@xsmx_dw", xsmxEntity.xsmx_dw),
                     new OleDbParameter("@xsmx_sl", xsmxEntity.xsmx_sl),
                     new OleDbParameter("@xsmx_gg", xsmxEntity.xsmx_gg),
                     new OleDbParameter("@xsd_code", xsmxEntity.xsd_code)};
            sql = "insert into xs_xsmx(xsmx_pm,xsmx_dj,xsmx_dw,xsmx_sl,xsmx_gg,xsd_code) values " +
                    "(@xsmx_pm,@xsmx_dj,@xsmx_dw,@xsmx_sl,@xsmx_gg,@xsd_code)";
            DbHelperOleDb.ExecuteSql(sql, parameters);
        }

        /// <summary>
        /// 删除销售明细
        /// </summary>
        /// <param name="XsmxEntity">销售明细实体类</param>
        public void DelxsmxByXsdcode(string xsd_code)
        {
            string sql = string.Empty;
            OleDbParameter[] parameters = {
                     new OleDbParameter("@xsd_code", xsd_code)};
            sql = "delete from xs_xsmx where xsd_code=@xsd_code";
            DbHelperOleDb.ExecuteSql(sql, parameters);
        }

        /// <summary>
        /// 查询销售单表
        /// </summary>
        /// <param></param>
        /// <returns></returns>
        public DataTable GetXsmxDt(string Xsd_code)
        {
            string sql = string.Empty;
            OleDbParameter[] parameters = {new OleDbParameter("@Xsd_code", Xsd_code)};
            sql = "select xsmx_code as 销售明细编码,xsmx_pm as 品名,xsmx_dj as 单价," +
                "xsmx_dw as 单位,xsmx_sl as 数量,xsmx_gg as 规格,xsd_code as 销售单编码" +
                " from xs_xsmx where xsd_code=@Xsd_code ";
            return DbHelperOleDb.ExecuteWithDataTable(sql, parameters);
        }
    }
}
